TPW HOUSELIGHTS
==========================

Version: 1.081
Released: 20120604
Authors: tpw
Requires: CBA
Runs on : Arma2, Operation Arrowhead, Combined Operations

Changelog: 
1.00 - initial release 20120510
1.01 - Can now be configured from hpp file. Lights are removed from houses after player leaves area.
1.02 - Not released
1.03 - Lights can flicker. 3 different light types, each fully configurable for brightness, colour and flickering. Miscellaneous improvements.
1.04-1.06 - Not released
1.07 - Total overhaul of code for true dynamic lights. Lights only flicker within a configurable distance of player to save CPU. Distant lights are brighter to compensate for limitations in lighting engine.
1.08 - Minor bugfixes, initialisation hint is configurable     
1.081 - Config bugfixes 


This addon causes lights to automatically come on in enterable buildings around the player after dark. It will work on any map with ALICE2 compatible enterable buildings, and will simply ignore unenterable ALICE buildings. Sick and tired of villages being pitch black after dark? This addon will create a flickering glow from houses at night which greatly increases immersion. 


How it works:
-------------
At startup it scans all houses within a 20km radius of the player, and any enterable houses are placed into a houses array.
Each house in the array is then given its own set of lighting parameters, and a lit/unlit status. Every 15 seconds the houses array is scanned, and any unlit house within the player's specified radius has a light source created using the lighting parameters associated with that house, if the sun is below the horizon. Any lit house outside the radius has its light removed.


Shortcomings:
-------------
The addon requires CBA to launch properly. If anyone knows of a way to convert a simple script into a PBO in a way that does not require CBA then I'd like to know about it.

The addon works in SP and MP (but not on a dedicated server). Owing to the various randomisation features of the script, different MP players may see different lights even if at the same location on the map. If you are playing MP and require all players to see the same lights at the same point on a map, then please use the MP version of this addon.  The CPU and network overhead, and my coding inability, prevents me from implementing true light source synchronisation. You are welcome to examine the heavily commented code to see if there is a way a dedicated server synchronised MP solution is achievable. 

Light sources don't seem to stress the engine too hard, but flickering light sources can. Default settings put lights into 30 or fewer houses, with 5-6 of them flickering. You may need to adjust the settings if you find your performance suffering.


How to use it:
--------------
Install: Copy the @TPW_HOUSELIGHTS modfolder to your preferred mod location, and call it via command line or mod launcher. You must also copy userconfig/TPW_HOUSELIGHTS/TPW_HOUSELIGHTS.hpp to your Arma2 userconfig/TPW_HOUSELIGHTS/TPW_HOUSELIGHTS.hpp. This config file can be edited to taste and is well commented, so it's easy to change appropriately.


Feedback:
---------
I'm a shit coder and no doubt this can be improved. I would value any feedback and suggestions, so give me your 2 cent's worth on the BIS forum.

Thanks:
-------
*Das Attorney for showing me how to create PBO addons, and for general advice. 
*CarlGustaffa for his excellent azimuth code. 
*Rydygier for his inspiration to right my own flickering code.
*RogueTrooper for improved enterable building code.
*Xeno for config and server advice.
*Demon Cleaner and Muzzleflash for code optimisation and cleanup.
*Twistking for excellent suggestions re light source uniformity for MP.

As always, thanks to BIS for a fantastic piece of software, and for the incredible community on the BIS froum. 

tpw